window.onload = function () {
    // 图片滚动
    ScrollReveal().reveal('.center', {
        distance: '450px',
        // 持续时间
        duration: 800,
        // 动画效果
        easing: 'ease-out',
        origin: 'top',
        opacity: 0.6,
        // reset: true
    })

    // 句子滚动
    ScrollReveal().reveal('.novles', {
        distance: '180px',
        // 持续时间
        duration: 1800,
        // 动画效果
        easing: 'ease-in-out',
        origin: 'right',
        opacity: 0.6,
        // reset: false
    })

    enforceTip();
    // 获取图标，绑定点击事件
    var xiahua = document.querySelector('.xiahua');
    xiahua.onclick = function () {
        // 使得第二个页面滑动
        ScrollReveal().reveal('.capital', {
            distance: '180px',
            // 持续时间
            duration: 900,
            // 动画效果
            easing: 'ease-in-out',
            origin: 'top',
            // opacity: 0.6,
            // reset: true
        })
        ScrollReveal().reveal('.function1', {
            distance: '380px',
            // 持续时间
            duration: 1000,
            // 动画效果
            easing: 'ease-in-out',
            origin: 'right',
            // opacity: 0.6,
            // reset: true
        })

        ScrollReveal().reveal('.function2', {
            distance: '380px',
            // 持续时间
            duration: 1500,
            // 动画效果
            easing: 'ease-in-out',
            origin: 'right',
            // opacity: 0.6,
            // reset: true
        })

    }

    // 获取退出登录遮盖层
    var container4 = document.querySelector('.container4');
    // 获取退出登录按钮，绑定点击事件
    var btn = document.querySelector('.btn');
    // 获取取消按钮
    var vanish = document.querySelector('.vanish');
    // 获取确认按钮
    var decide = document.querySelector('.decide');
    // btn.onclick = function () {
    //     container4.style.display = 'block';
    // }

    btn.onclick = function () {
        // 利用本地路径进行跳转
        container4.style.display = 'block';
        decide.onclick = function () {
            window.location.href = '/Login.html';
        }
        vanish.onclick = function () {
            container4.style.display = "none";
        }
    }


    // 获取数学链接，绑定事件
    var math = document.querySelector('.new-book1');
    math.onclick = function () {
        window.location.href = '../systematic/library.html';
    }

    // 获取修改
    var reset = document.querySelector('.reset');
    var container = document.querySelector('.container');
    // 获取修改成功
    var container1 = document.querySelector('.container1');
    var container2 = document.querySelector('.container2');
    // 获取确认
    var determine = document.querySelector('.determine');
    // 点击修改显示隐藏
    reset.onclick = function () {
        container.style.display = 'block';
    }

    // 点击确认显示
    determine.onclick = function () {
        container.style.display = "none";
        var success = setTimeout(function () {
            container2.style.display = 'block';
        }, 800)
        var success = setTimeout(function () {
            container2.style.display = 'none';
        }, 1300)

        // if (determine === true) {
        //     container.style.display = 'none';
        //     var success = setTimeout(function () {
        //         container1.style.display = 'block';
        //     }, 800)
        //     var success = setTimeout(function () {
        //         container1.style.display = 'none';
        //     }, 1300)
        // } else {
        //     container.style.display = 'none';
        //     var success = setTimeout(function () {
        //         container1.style.display = 'block';
        //     }, 800)
        //     var success = setTimeout(function () {
        //         container1.style.display = 'none';
        //     }, 1300)
        // }
    }
    // 点击取消则继续隐藏
    var canle = document.querySelector('.canle');
    canle.onclick = function () {
        container.style.display = 'none';
    }


    // 还书提醒
    function enforceTip(){
        $.ajax({
            type:'get',
            url:'/selectTime',
            dataType:'json',
            success(data) {
                console.log(data)
                if(data[0]!=null) {
                    $('.big-tip').show();
                    let textTip="<p>您以下书籍已到期！赶紧还书吧</p>" + "<span class='dataTip'>";
                    for(var i in data){
                        console.log(data[i].bookName)
                        textTip +="《"+ data[i].bookName +"》"+ "<br>" ;
                    }
                    textTip+= "</span>";
                    var text="<button class='certain'>确定</button>"
                    $('.outTip').append(textTip)
                    $('.outTip').append(text)

                }else{
                    $('.big-tip').hide();
                }
                $('.certain').click(function () {
                    $('.big-tip').hide();
                })
            }
        })
    }

}